

import Event from "../event"

export default class MouseEvent extends Event{

  constructor(viewer){
    super()
    this._viewer = viewer
    this._handler = new Cesium.ScreenSpaceEventHandler(this._viewer.canvas)
    this._setInputaction()
  }

  /**
   *  注册鼠标事件
   */
  _setInputaction(){
    Object.keys(Cesium.ScreenSpaceEventType).forEach(key => {
      let type = Cesium.ScreenSpaceEventType[key]
      this._cache[type] = new Cesium.Event()
      this._handler.setInputAction(movement => {
        this._cache[type].raiseEvent(movement)
      }, type)
    })
  }

  /**
   * 销毁对象
   */
  destroy(){
    this._cache = {}
    this._viewer = undefined
    this._handler.destroy()
  }

  /**
   * 增加自定义事件
   */
  addToCache(){}
}